package com.smartao.extend;

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Date extends java.util.Date {

	private static final long serialVersionUID = 5433432998300911422L;

	private static final String[] SHORT_WEEKS = { "周日", "周一", "周二", "周三", "周四", "周五", "周六" };
	private static final String[] FULL_WEEKS = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
	private static final String DAY = "M月dd日";
	private static final String DAY_YEAR = "yyyy年MM月dd日";
	private static final String TIME = "HH:mm";
	private static final String TIME_DAY = "M月dd日 HH:mm";
	private static final String TIME_DAY_YEAR = "yyyy年MM月dd日 HH:mm";

	private Calendar calendar = Calendar.getInstance();

	public Date() {
		super();
		calendar.setTime(this);
	}

	public Date(long date) {
		super(date);
		calendar.setTime(this);
	}

	/**
	 * 返回 如"周一，周二"
	 */
	public String getShortWeek() {
		return SHORT_WEEKS[calendar.get(Calendar.DAY_OF_WEEK) - 1];
	}

	/**
	 * 返回 如"星期一，星期二"
	 */
	public String getFullWeek() {
		return FULL_WEEKS[calendar.get(Calendar.DAY_OF_WEEK) - 1];
	}

	/**
	 * 返回如 7月8日
	 */
	public String getShortDay() {
		SimpleDateFormat sdf = new SimpleDateFormat(DAY);
		return sdf.format(this);
	}

	/**
	 * 返回如2012年7月8日
	 */
	public String getFullDay() {
		SimpleDateFormat sdf = new SimpleDateFormat(DAY_YEAR);
		return sdf.format(this);
	}

	/**
	 * 返回如12:34
	 */
	public String getShortTime() {
		SimpleDateFormat sdf = new SimpleDateFormat(TIME);
		return sdf.format(this);
	}

	/**
	 * 返回如7月8日12:24
	 */
	public String getDayTime() {
		SimpleDateFormat sdf = new SimpleDateFormat(TIME_DAY);
		return sdf.format(this);
	}

	/**
	 * 返回如2012年7月8日12:24
	 */
	public String getFullTime() {
		SimpleDateFormat sdf = new SimpleDateFormat(TIME_DAY_YEAR);
		return sdf.format(this);
	}

}
